package com.cm.projectx.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private int code;
    private String msg = "业务成功";
    private HashMap<String, Object> data;

    public static final Result SUCCESS = new Result(0, "业务成功", null);
    public static final Result FAILED = new Result(-1, "业务失败", null);

    public void addData(String key, Object value) {
        if (this.data == null) {
            this.data = new HashMap<>();
        }
        this.data.put(key, value);
    }

    public void addData(Map data) {
        if (this.data == null) {
            this.data = new HashMap<>();
        }
        this.data.putAll(data);
    }
}
